<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>算术运算符</title>
</head>

<body>
    <script>
        //  +  -  *  /  %(取余)
        var x = 10,
            y = 5;
        console.log("x + y =", x + y); // 输出：x + y = 14
        console.log("x - y =", x - y); // 输出：x - y = 6
        console.log("x * y =", x * y); // 输出：x * y = 40
        console.log("x / y =", x / y); // 输出：x / y = 2.5
        console.log("x % y =", x % y); // 输出：x % y = 2

        console.log(3 % 5);

        console.log(4 / 2); //2
        console.log(10 % 3); //1

        // 浮点数的精确的问题
        console.log(0.1 + 0.1); //0.2
        console.log(0.1 + 0.2); //0.30000000000000004

        console.log(0.1 * 100); // 10
        console.log(0.06 * 100); // 6
        console.log(0.08 * 100); // 8
        console.log(0.07 * 100); // 7.000000000000001 
        // 所以不要直接判断两个浮点数是否相等

        var num = 0.1 + 0.2;
        console.log(num == 0.3);
    </script>
</body>

</html>